package io.renren.modules.police.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.utils.ConvertUtils;
import io.renren.modules.police.dao.PoliceServiceTypeDao;
import io.renren.modules.police.dto.PoliceServiceTypeDTO;
import io.renren.modules.police.entity.PoliceServiceTypeEntity;
import io.renren.modules.police.service.PoliceServiceTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 服务类型表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-09-02
 */
@Service
public class PoliceServiceTypeServiceImpl extends CrudServiceImpl<PoliceServiceTypeDao, PoliceServiceTypeEntity, PoliceServiceTypeDTO> implements PoliceServiceTypeService {

    @Override
    public QueryWrapper<PoliceServiceTypeEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<PoliceServiceTypeEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<PoliceServiceTypeDTO> getServiceTypes(Map<String, Object> params) {
        List<PoliceServiceTypeEntity> entityList = this.baseDao.selectList(null);
        return ConvertUtils.sourceToTarget(entityList, PoliceServiceTypeDTO.class);
    }
}